<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

<body>
    <div id="app">
        <!-- 事件 -->
        <input type="text" v-model="msg" @input="handleChange">
    </div>
    <script>
        // 搜索框每间隔100ms发送http请求
        var vm = new Vue({
            el: '#app',
            data: {
                msg: "hello",
                timer: null
            },
            methods: {
                handleChange() {
                    if (this.timer) {
                        return
                    }
                    this.timer = setTimeout(() => {
                        var url = `http://122.112.161.135:3000/search?keywords=${this.msg}`;
                        console.log(url);
                        this.timer = null
                    }, 1000)
                }
            }
        })
    </script>
</body>

</html>